package cn.okcode.api.framework.result;

import cn.okcode.api.framework.ActionException;

/**
 * 相应结果处理器工厂
 * 根据注解类型，创建对应的结果处理器
 *
 * @author pyk13
 */
public class ResultHandlerFactory {
    public static ResultHandler createHandler(ResultHandlerEnum handlerEnum) {
        if (ResultHandlerEnum.STATUS.equals(handlerEnum)) {
            return new StatusResultHandler();
        } else if (ResultHandlerEnum.RAW.equals(handlerEnum)) {
            return new RawResultHandler();
        } else {
            throw new ActionException("未知的处理类型:[" + handlerEnum.value() + "]");
        }
    }
}